<?php
class View_Message_Forward extends View_Message
{
	/**
	 *	...
	 *	@access		private
	 *	@return		string
	 */
	public function buildContent()
	{
		$words		= $this->words['message']['forward'];

		if( $messageId	= $this->request->get( 'messageId' ) )
		{
			$message	= Logic_Message::getMessage( $messageId );

			$current	= $this->auth->getCurrentUser();

			$users		= Logic_User::getUsers();
			$opt_receivers	= array();
			foreach( $users as $user )
				if( $user['userId'] != $current )
					if( $user['userId'] != $message['source'] )
						$opt_receivers[$user['userId']] = $user['username'];
			if( $this->request->get( 'forward_receivers' ) )
				$opt_receivers['_selected']	= $this->request->get( 'forward_receivers' );

			//  --  COMPONENTS  --  //
			if( !( $subject	= $this->request->get( 'forward_subject' ) ) )
				$subject	= "FW: ".$message['subject'];
			if( !( $body	= $this->request->get( 'forward_body' ) ) )
				$body		= $this->getBodyCite( $message, $words['header'] );

			$formData		= array(
				'subject'	=> $subject,
				'body'		=> $body,
				);
			$formOptions	= array(
				'opt_receivers' => $opt_receivers
			);

			$urlForm		= self::getUrl( array( 'action' => 'forward' ) );
			$urlCancel		= self::getUrl( array( 'messageId' => $messageId ) );
			$labelCancel	= $words['buttonCancel'];
			$labelForward	= $words['buttonForward'];
			$ui	= array(
				'words'			=> $words,
				'form'			=> $this->buildForm(
					'message',
					'forwardMessage',
					'message',
					'forward',
					$formData,
					$formOptions
				),
				'buttonCancel'	=> $this->html->LinkButton( $urlCancel, $labelCancel, 'but cancel' ),
				'buttonForward'	=> $this->html->Button( 'forwardMessage', $labelForward, 'but edit' ),
				'form.tag'		=> $this->html->Form( 'sendMessage', $urlForm ),
				'colgroup'		=> $this->html->ColumnGroup( "25%", "75%" ),
				'caption'		=> $this->html->TableCaption( $words['caption'] ),
			);
			return $this->loadTemplate( 'message.forward', $ui );
		}
	}
}
?>